Skip to content

Conversation

@Robdel12
Copy link
Contributor

@Robdel12 Robdel12 commented Jan 7, 2026

Summary

Adds the type field to all SDK clients that send screenshot image data. This completes the performance optimization from #174 by ensuring all clients benefit from O(1) type detection on the server.

Changes

SDK File Type Sent
Full SDK src/sdk/index.js type: 'base64'
Vitest clients/vitest/src/setup.js type: 'file-path'
Ruby clients/ruby/lib/vizzly.rb type: 'base64'
Swift clients/swift/.../VizzlyClient.swift type: 'base64'

No changes needed:

Packages to Release

After merging, the following packages need new releases:

Package Registry Notes
@vizzly-testing/cli npm Main CLI package
@vizzly-testing/vitest npm Vitest plugin
vizzly RubyGems Ruby gem
Vizzly Swift Package Manager Swift package

Test Plan

  • All 1751 tests pass
  • Backwards compatible (server falls back to detection if type missing)

All SDK clients now send 'type' field with screenshot requests:
- src/sdk/index.js: type: 'base64'
- clients/vitest/src/setup.js: type: 'file-path'
- clients/ruby/lib/vizzly.rb: type: 'base64'
- clients/swift/Sources/Vizzly/VizzlyClient.swift: type: 'base64'

This eliminates O(n) image type detection on the server side,
providing significant performance improvement for large screenshots.
@claude
Copy link

claude bot commented Jan 7, 2026

Code Review - PR #175

Summary

This PR completes the performance optimization started in #174 by adding the explicit type field to all remaining SDK clients. The changes are minimal, focused, and correctly implemented.

✅ Strengths

  1. Consistent Implementation: All four SDK clients correctly add the type field matching their data format:

    • src/sdk/index.js:255 - type: 'base64'
    • clients/vitest/src/setup.js:63 - type: 'file-path'
    • clients/ruby/lib/vizzly.rb:58 - type: 'base64'
    • clients/swift/Sources/Vizzly/VizzlyClient.swift:82 - type: 'base64'
  2. Excellent Test Coverage: Server-side tests verify that explicit type parameters skip detection (tests/server/handlers/tdd-handler.test.js:759-804, tests/server/handlers/api-handler.test.js:180-225)

  3. Backwards Compatibility: PR ⚡ Skip image type detection when SDK provides explicit type #174 implemented fallback detection, so old clients without type field continue working

  4. Complete Analysis: PR description correctly identifies which clients don't need changes:

    • Core client - Already updated in ⚡ Skip image type detection when SDK provides explicit type #174
    • Static-site & Storybook - Use core client SDK (verified in clients/storybook/src/screenshot.js:10 and clients/static-site/src/screenshot.js:10)
    • Ember - Different architecture (sends selector, server takes screenshot - verified in clients/ember/src/launcher/screenshot-server.js:241-256)
  5. Clear Documentation: PR body provides excellent table showing which packages need releasing

🔍 Minor Observations

  1. No Client-Side Tests: The SDK clients themselves (Ruby, Swift, Vitest) don't have unit tests in this repo that verify the type field is sent. However:

    • Server-side tests confirm the field is used correctly when received
    • The changes are trivial (adding one field to a payload)
    • Tests would need separate test infrastructure for each language
    • Not blocking, but worth noting for future
  2. Swift Syntax: The Swift code uses proper dictionary literal syntax (line 82: "type": "base64") - looks good

  3. Ruby Syntax: The Ruby code correctly uses symbol keys with string value (line 58: type: 'base64') - consistent with the rest of the payload

🎯 Performance Impact

This PR completes the optimization that eliminates O(n) regex validation on large base64 strings. For multi-megabyte full-page screenshots, this provides significant speedup as the server can now skip expensive type detection entirely.

✅ Recommendation

Approve and merge.

The implementation is correct, well-tested at the integration level, and completes the performance optimization from #174. All four SDK clients now benefit from O(1) type detection on the server.

Post-merge checklist (as noted in PR description):

  • Release @vizzly-testing/cli to npm
  • Release @vizzly-testing/vitest to npm
  • Release vizzly gem to RubyGems
  • Release Vizzly Swift package

Review completed: Code quality ✓, Performance ✓, Security ✓, Test coverage ✓

The tests were expecting cloud mode response format (success: true) but the
integration tests run against TDD mode which returns status: 'new' or 'match'.
@Robdel12 Robdel12 enabled auto-merge (squash) January 7, 2026 02:34
@Robdel12 Robdel12 merged commit 507cd47 into main Jan 7, 2026
25 of 28 checks passed
@Robdel12 Robdel12 deleted the perf/sdk-explicit-type branch January 7, 2026 02:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants